﻿<UserControl x:Class="MicroBlogClient.UCLogin"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"  PreviewKeyDown="UserControl_PreviewKeyDown"
             d:DesignHeight="500" d:DesignWidth="300">
    <Border Style="{DynamicResource MainWindowBorder}" BorderThickness="0">
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Center">
                <Canvas Background="{DynamicResource LoginBanner}" Height="236" Width="304"/>
                <StackPanel x:Name="panelUserAccount" Margin="0,-50,0,0" HorizontalAlignment="Center">
                    <StackPanel  
                        Visibility="{Binding IsChecked,Mode=OneWay, 
                        Converter={StaticResource ContrastBooleanToVisibilityConverter}, 
                        ElementName=chkNewUser}">
                        <TextBlock Text="账号:"   Style="{StaticResource AppTitleStyle}"/>
                        <ComboBox TextSearch.TextPath="UserName"  x:Name="txtUserName"
                          SelectedIndex="0"
                           SelectionChanged="txtUserName_SelectionChanged"
                          IsEditable="True" 
                          Background="White" 
                          SelectedValuePath="UserID" 
                          BorderBrush="{DynamicResource UserListComboBoxBorderBrush}" 
                          HorizontalAlignment="Left" 
                          Width="147">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Width="147" Height="25" VerticalAlignment="Center">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="25" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Grid.Column="0" VerticalAlignment="Center" Text="{Binding UserName}" />
                                        <Button Style="{DynamicResource DeleteUserButtonStyle}"  Width="14" Height="12" Grid.Column="1" x:Name="btnDeleteMe" Click="btnDeleteMe_Click"  CommandParameter="{Binding UserID}"/>
                                    </Grid>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <TextBlock Text="密码:" Margin="0,10,0,0"   Style="{StaticResource AppTitleStyle}"/>
                        <PasswordBox  Height="23"  GotFocus="textBox_GotFocus"
                              Name="txtPassword" Width="147" />
                        
                        <CheckBox x:Name="chkRememberPassword" IsChecked="True" Margin="0,5,0,0">
                            <TextBlock Style="{StaticResource AppTitleStyle}" Text="记住密码"/>
                        </CheckBox>
                    </StackPanel>
                    <StackPanel  Visibility="{Binding IsChecked,Mode=OneWay, 
                Converter={StaticResource BooleanToVisibilityConverter}, 
                ElementName=chkNewUser}">
                        <TextBlock Text="授权码:" ToolTip="验证码是指在打开的网页中，授权本应用之后返回的一串数字"  Style="{StaticResource AppTitleStyle}"/>
                        <StackPanel Orientation="Horizontal">
                            <TextBox Height="23" Name="txtVerifyCode"
                         Width="120" />
                            <TextBlock VerticalAlignment="Center" >
                            <Hyperlink Click="linkGetVerifyCode_Click">
                                <TextBlock Style="{StaticResource AppTitleStyle}" Text="点击获取"/>
                            </Hyperlink>
                        </TextBlock>
                        </StackPanel>
                    </StackPanel>
                    <CheckBox x:Name="chkNewUser" ToolTipService.InitialShowDelay="0" Margin="0,5,0,0">
                        <TextBlock  Style="{StaticResource AppTitleStyle}" Text="想安全登录？"/>
                        <CheckBox.ToolTip>
                            <TextBlock Width="120" TextWrapping="Wrap">
                        安全登录是指您通过搜狐微博官网授权本应用可以访问您的微博等信息，选择这种登录方式后，请您在打开的浏览器中授予本应用权限，将搜狐微博返回的授权码输入到本应用中即可。
                            </TextBlock>
                        </CheckBox.ToolTip>
                    </CheckBox>

                    <StackPanel Orientation="Horizontal" Margin="0,10,0,0" >
                        <Button Content="登录" 
                                 VerticalAlignment="Center"
                                Height="23" Name="btnLogin"
                                Click="btnLogin_Click" Width="75" />
                        <CheckBox x:Name="chkIsOnline" Margin="10,0,0,0" 
                                  Foreground="{StaticResource AppTitleColorBrush}" IsChecked="True"
                                  VerticalAlignment="Center" Content="在线上"/>
                    </StackPanel>
                </StackPanel>

                <StackPanel Visibility="Collapsed" x:Name="cancelPanel" HorizontalAlignment="Center">
                    <TextBlock Text="正在登录..." Style="{StaticResource AppTitleStyle}" />
                    <Button Content="取消登录" x:Name="btnCancel" Width="75"  Click="btnCancel_Click"/>
                </StackPanel>
            </StackPanel>
        <TextBlock Grid.Row="1" Margin="30,0,0,30">
            <Hyperlink Click="linkRegister_Click">
                <TextBlock Style="{StaticResource AppTitleStyle}" Text="注册新账号"/>
            </Hyperlink>
            <LineBreak/>
            <Hyperlink Click="linkPasswordRecovery_Click">
                <TextBlock Style="{StaticResource AppTitleStyle}" Text="忘记密码？"/>
            </Hyperlink>
            <LineBreak/>
            <Hyperlink Click="linkMyWebsite_Click">
                <TextBlock Style="{StaticResource AppTitleStyle}" Text="微兔软件"/>
            </Hyperlink>
        </TextBlock>
    </Grid>
    </Border>
</UserControl>
